<?
define('IN_LC', true);
define('MM_ID', 0);

include_once('../validate.php');

function displayDrivers($key)
{
	global $lang;
	
	echo '<p class="tableInfoNoPadding">';
	foreach($_SESSION[$key] as $driverID => $driverDetails)
	{
		echo $driverDetails['name'] . ' (' . ($driverDetails['role'] == 0 ? $lang['IncidentAtFault'] : $lang['IncidentVictim']) . ') ' . 
		'<a href="#" onClick="getRemoveDriver(' . $driverID . ')">' . $lang['RemoveButton'] . '</a>' .
		'<br>';
	}
	echo '</p>';
}

if(isset($_GET['add']) && $_GET['add'] == 1 && isset($_GET['driverName'])&& isset($_GET['role'])&& isset($_GET['driverID']))
{
	$key = 'incident';
	if(! isset($_SESSION[$key]))
	{
		$_SESSION[$key] = Array();
	}
	
	//add driver to session data
	$driver = Array();
	$driver['name'] = $_GET['driverName'];
	$driver['role'] = $_GET['role'];
	
	$_SESSION[$key][$_GET['driverID']] = $driver;
	
	displayDrivers($key);
	
}
else if(isset($_GET['add']) && $_GET['add'] == 0 && isset($_GET['driverID']))
{
	$key = 'incident';
	unset($_SESSION[$key][$_GET['driverID']]);
	displayDrivers($key);
}
else
{
	print_r($_GET);
}
?>